package com.aso114.project.util;

//����

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.preference.PreferenceManager;

public class MySharedPreferences {

	private static MySharedPreferences mSharedPreferences;
	private static SharedPreferences sPref;
	private static Context mContext;
	public static String staustype = "";
	public static String cityversion = "";// 网络城市编码版本 判断是否需要下载
	public static String Nowcityversion = "1.0.1";// 现在城市编码版本 判断是否需要下载



	private static final String isFirstRun = "sp_isfirstrun";
	private static final String uniName = "uniname";
	private static final String loginLine = "islogin";
	private static final String cityVersion = "cityversion";
	private static final String loginUid = "sp_loginuid";
	private static final String textsize="textsize";
	private static final String tellnumber = "sp_tellnumber";
	private static final String head_img_url = "head_img_url";
	public Editor editor;
	private static final String univisityid = "univisityid";
	private static final String isvibrate = "isvibrate";
	private static final String ssid = "ssid";
	private static final String countvison = "countvison";

	public static MySharedPreferences getInstance(Context context) {
		mContext = context;
		sPref = PreferenceManager.getDefaultSharedPreferences(mContext);
		if (mSharedPreferences == null) {
			mSharedPreferences = new MySharedPreferences();
		}
		return mSharedPreferences;
	}

	public void setTostVison(int count) {
		sPref.edit().putInt(countvison, count).commit();
	}

	public int getTostVison() {
		return sPref.getInt(countvison, 0);// 当Count不存在的时候，返回的是默认值0；所以Num=0；
		// 当Count存在的时候，返回的是它存储的数据;
	}

	// �����Ƿ��һ������
	public void setIsLogin(boolean b) {
		sPref.edit().putBoolean(isFirstRun, b).commit();
	}

	public boolean getIsLogin() {
		return sPref.getBoolean(isFirstRun, true);
	}

	public void setIsVibrate(boolean b) {
		sPref.edit().putBoolean(isvibrate, b).commit();
	}

	public boolean getIsVibrate() {
		return sPref.getBoolean(isvibrate, true);
	}

	public void setLoginLine(String login) {
		sPref.edit().putString(loginLine, login).commit();
	}

	public String getLoginLine() {
		return sPref.getString(loginLine, "");
	}

	public void setCityVersion(String version) {
		sPref.edit().putString(cityVersion, version).commit();
	}

	public String getCityVersion() {
		return sPref.getString(cityVersion, "");
	}

	// ��¼�ʻ����
	public void setUniName(String name) {
		sPref.edit().putString(uniName, name).commit();
	}

	public String getUniName() {
		return sPref.getString(uniName, "");
	}

	public void setSsId(String id) {
		sPref.edit().putString(ssid, id).commit();
	}

	public String getSsId() {
		return sPref.getString(ssid, "");
	}

	public void setUnivisityId(String id) {
		sPref.edit().putString(univisityid, id).commit();
	}

	public String getUnivisityId() {
		return sPref.getString(univisityid, "");
	}

	// ��¼id
	public void setTextSize(int size) {
		sPref.edit().putInt(textsize, size).commit();
	}

	public int getTextSize() {
		return sPref.getInt(textsize, 3);
	}


	public void setLoginUid(String uid) {
		sPref.edit().putString(loginUid, uid).commit();
	}

	public String getLoginUid() {
		return sPref.getString(loginUid, "");
	}

	public boolean getBooleanParams(String key) {
		return sPref.getBoolean(key, false);
	}

	public boolean getBooleanParams(String key, boolean value) {
		return sPref.getBoolean(key, value);
	}

	public void setBooleanParams(String key, boolean value) {
		sPref.edit().putBoolean(key, value);
		sPref.edit().commit();
	}

	// �ֻ����ע��
	public void setTellResister(String number) {
		sPref.edit().putString(tellnumber, number).commit();
	}

	public String getTellResister() {
		return sPref.getString(tellnumber, "");
	}

	// ͷ���ַ
	public void setHeadimage(String url) {
		sPref.edit().putString(head_img_url, url).commit();
	}

	public String getHeadimage() {
		return sPref.getString(head_img_url, "");
	}

	// public static MySharedPreferences getInstance(
	// MainNewsActivity mainNewsActivity) {
	// // TODO Auto-generated method stub
	// return null;
	// }

}
